# import requests
# from util.get_time_stamp import get_time_stamp
# import execjs
# import hashlib
#
# with open("./parse/逆向还原福建公共交易平台.js") as f:
#     js_str = f.read()
#     js_code = execjs.compile(js_str, cwd="./parse")
#
#
#
#
# page = 1
#
# e = {
#     "ts": get_time_stamp(),
#     "pageNo": page,
#     "pageSize": 20,
#     "total": 3413,
#     "KIND": "GCJS",
#     "GGTYPE": "1",
#     "timeType": "6",
#     "BeginTime": "2025-05-20 00:00:00",
#     "EndTime": "2025-11-20 23:59:59"
# }
#
# n = js_code.call('d', e)
# sign = hashlib.md5(n.encode()).hexdigest()
#
# e.update({
#     "AREACODE": "",
#     "M_PROJECT_TYPE": "",
#     "PROTYPE": "",
#     "createTime": "",
# })
#
#
# res = requests.post('https://ggzyfw.fj.gov.cn/FwPortalApi/Trade/TradeInfo', json=e, headers={
#     'portal-sign': sign,
# })
#
# # print(res.json()['Data'])
#
# r = js_code.call("b", res.json()['Data'])
# print(r)
#
#

import os
os.environ["EXECJS_RUNTIME"] = "Node"
os.environ["NODE_EXE"] = r"D:\Node.js\node.exe"   # 必须是你 where node 的结果
import requests
from util.get_time_stamp import get_time_stamp
import execjs
import hashlib

with open("./parse/逆向还原福建公共交易平台.js") as f:
    js_str = f.read()
    js_code = execjs.compile(js_str, cwd="./parse")




page = 1

e = {
    "ts": get_time_stamp(),
    "pageNo": page,
    "pageSize": 20,
    "total": 3413,
    "KIND": "GCJS",
    "GGTYPE": "1",
    "timeType": "6",
    "BeginTime": "2025-05-20 00:00:00",
    "EndTime": "2025-11-20 23:59:59"
}


n = js_code.call("d", e)
sign = hashlib.md5(n.encode()).hexdigest()
print(sign)

e.update({
    "AREACODE": "",
    "M_PROJECT_TYPE": "",
    "PROTYPE": "",
    "createTime": "",
})



res = requests.post('https://ggzyfw.fj.gov.cn/FwPortalApi/Trade/TradeInfo', json=e, headers={
    'portal-sign': sign,
})

print(res.json()['Data'])

r = js_code.call("b", res.json()['Data'])
print(r)
